// pages/collage-detail/collage-detail.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    numzong: 0,
    priceszong: 0,
    shop: {
     
    },
    src1:'../../images/jiantouyou.png',
    src2:'../../images/jiantouxia.png',
    active:1,
    contents:[
     
    ],
    yuanprice:'24',
    pinprice:'18'
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this 
    wx.request({
      url: app.globalData.directory + 'api/v2/getCollageDetails/' +options.id,
      header: {
        'content-type': 'application/json', // 默认值
        'token': wx.getStorageSync('token')
      },
      success:function(res){
        if(res.data.status =="ok"){
           that.setData({
             shop:res.data.data
           })
          
        }else{
          wx.showToast({
            title: '请求失败,请重试',
            icon: 'none',
            duration: 2000,
          })
        }
      }
    })
  },

  toBuy:function(e) {
   
    var id = e.currentTarget.id
    
    wx.navigateTo({
      url: '../confirmorder/confirmorder?id='+id,
    })
  },
  chakan:function(e){
    // 点击事件重新请求数据
    if (this.data.active == 1 ){
      var contents = [];
      for (var i = 0; i < 6; i++) {
        var content = this.data.contents[i];
        contents.push(content)
      }
      console.log(contents)
      this.setData({
        active:0,
        contents: contents
      })
     
    } else{
      var contents = [];
      for (var i = 0; i < 3; i++) {
        var content = this.data.contents[i];
        contents.push(content)
      }
      this.setData({
        active:1,
        contents: contents
      })
     
    }
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})